package cn.tedu.property_management_system.service.Impl;

import cn.tedu.property_management_system.entity.Complaint;
import cn.tedu.property_management_system.entity.ComplaintType;
import cn.tedu.property_management_system.entity.RepairType;
import cn.tedu.property_management_system.mapper.ReportForRepairMapper;
import cn.tedu.property_management_system.service.ReportForRepairService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
@Slf4j
public class ReportForRepairServiceImpl implements ReportForRepairService {
    @Autowired
    private ReportForRepairMapper mapper;


    @Override
    public List<String> typeList() {
        List<RepairType> repairTypeList = mapper.repairTypes();
        List<String> list = new ArrayList<>();
        for (RepairType repairType : repairTypeList) {
            list.add(repairType.getType());
        }

        return list;
    }

    @Override
    public List<Integer> dataList() {
        List<Integer> list=new ArrayList<>();
        List<RepairType> repairTypeList = mapper.repairTypes();
        for (RepairType repairType : repairTypeList) {
            list.add(mapper.repairs(repairType.getId())==null?0:mapper.repairs(repairType.getId()));
        }
        return list;
    }

    @Override
    public List<String> compliantTypeList() {
        List<ComplaintType> complaintList = mapper.compliantType();

        List<String> list = new ArrayList<>();

        for (ComplaintType complaintType : complaintList) {

            list.add(complaintType.getType());

        }

        return list;
    }

    @Override
    public List<Integer> complaintList() {
        List<Integer> list=new ArrayList<>();

        List<ComplaintType> complaintTypes = mapper.compliantType();

        for (ComplaintType complaintType : complaintTypes) {
            list.add(mapper.complaint(complaintType.getType())==null?0:mapper.complaint(complaintType.getType()));
        }
        return list;
    }
}
